package com.huawei.appgallery.assistantdock.base.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;

public class FixedHeightImageView extends ImageView {
    public FixedHeightImageView(Context context) {
        super(context);
    }

    public FixedHeightImageView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public FixedHeightImageView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        if (getDrawable() != null) {
            int intrinsicHeight = getDrawable().getIntrinsicHeight();
            int intrinsicWidth = getDrawable().getIntrinsicWidth();
            if (intrinsicHeight > 0) {
                int measuredHeight = getMeasuredHeight();
                setMeasuredDimension((int) ((((float) measuredHeight) / ((float) intrinsicHeight)) * ((float) intrinsicWidth)), measuredHeight);
            }
        }
    }
}
